<?php
	include_once("adb.php");
	
	class region extends adb{
		function region(){
			adb::adb();
		}
		/**
		*query all regions in the table and store the dataset in $this->result	
		*@return if successful true else false
		*/
		
		function get_all_region(){
			$query="select * from region";
			return $this->query($query);
		}
		
		function add_region($region_id,$region_name,$region_capital){
			//write the SQL query and call $this->query()
			$query="insert into region set region_id=$region_id,region_name='$region_name',region_capital='$region_capital'";
			return $this->query($query);
		}
		/**
		*updates the record identified by id 
		*/
		function update_region($region_id,$region_name,$region_capital){
			//write the SQL query and call $this->query()
			$query="update region set region_id=$region_id,region_name='$region_name',region_capital='$region_capital' where region_id='$region_id'";
			return $this->query($query);
		}
		
		function delete_region($region_id){
			$query="DELETE FROM region where region_id='$region_id'";
			return $this->query($query);
		}
		
		function get_region($id){
			$query="select * from region where region_id=$id";
			if(!$this->query($query)){
				return false;
			}
			return $this->fetch();
		}
		
	}
?>